package com.zr.corporatefactory.mapper;

import com.zr.corporatefactory.model.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import javax.validation.Valid;
import java.util.List;

/**
 * Created by 天赐 on 2019/12/24.
 */
@Mapper
public interface CorFacMapper {
    List<Factory> queryPage(PageSelectVo pageSelectVo);

    Integer queryCount(PageSelectVo pageSelectVo);


    @Update("update corporatefactory set legalPlantDec=#{legalPlantDec},cfstatus=#{cfstatus} where legalPlantCode=#{legalPlantCode}")
    void update(@Valid CorUpdate corUpdate);
    @Select("select count(*) from corporatefactory where legalPlantDec=#{legalPlantDec}")
    int queryByName(String legalPlantDec);

    Factory queryById(String legalPlantCode);

    @Update("update corporatefactory set cfstatus=#{enabled} where id=#{id}")
    void updateStatus(CorFacStatus corFacStatus);

    List<legalperson> getPersonName();

    @Insert("insert into corporatefactory(legalPlantDec,legalPlantCode,cfstatus,legalPersonCode) values(#{legalPlantDec},#{legalPlantCode},#{enabled},#{legalPersonCode})")
    void addCor(@Valid CorAdd corAdd);
    @Select("select * from corporate where legalPersonCode=#{legalPersonCode}")
    Corporate getPersonCode(String legalPersonCode);
}
